feat(julia): add Julia language support with vendored tree-sitter grammar#290
feat(julia): add Julia language support with vendored tree-sitter grammar#290hexu2 wants to merge 1 commit into
Conversation
ae7ae0e to
7a3c565
Compare
|
may need to solve conflicts with main branch |
|
我提议,我们可以先维护一个Julia能用,codegraph能安装、能正常使用。github cli能自动执行测试的版本。 |
7a3c565 to
13a4c11
Compare
…mmar Add tree-sitter-julia extraction with vendored WASM and registry wiring. Builds on colbymchenry#244 (@kongdd) with support for common Julia 1.11 AST shapes: - getName hook for symbols whose names are not direct nameField children - Structs without block wrappers (typed_expression children) via resolveBody - Functions without block wrappers — handled in visitNode: first signature-shaped child becomes the declaration head, remaining children are walked via visitFunctionBody so calls are still indexed. resolveBody returns null for these so the core walker cannot re-enter extractFunction and recurse. - One-line assignment functions (e.g. f(x) = expr) - module_definition mapped to module kind for namespace-scoped qualified names - macrocall_expression added to callTypes - Vendored tree-sitter-julia.wasm (not published in tree-sitter-wasms); same pattern as lua/luau/pascal/scala - Register .jl in grammars, types, and the language extractor map Co-authored-by: Cursor <cursoragent@cursor.com>
13a4c11 to
6ee89c4
Compare
|
@kongdd Thanks for the heads-up! I've rebased onto current While rebasing I also caught a regression that was masked before: when a Julia function has no Verification:
完全同意你之前的提议 —— 先维护一个 Julia 可用、安装/CI 都通过的版本,主线接收节奏不影响我们使用。如果想合到你那边作为基线,我也愿意把当前分支同步过去,或者一起 co-author。 PR description updated to match the current implementation. |
Summary
Adds first-class Julia (
.jl) indexing to CodeGraph using the tree-sitter-julia grammar.This PR extends and supersedes the groundwork in #244 by @kongdd (happy to co-author), with additional handling for common Julia AST shapes seen in real-world packages (including Julia 1.11):
blockwrappers —struct_definitionmay usetyped_expressionchildren instead of abody/block;extractStructresolves the body viaresolveBodyfor consistency with interface extraction.blockwrappers — many files use a flat statement list directly underfunction_definition. Handled injuliaExtractor.visitNode: the first signature-shaped child (signature/call_expression/typed_expression/where_expression) is treated as the declaration head, and the remaining children are walked viactx.visitFunctionBodyso nested calls (e.g.out_neighbors,topological_sort) are still indexed.resolveBodydeliberately returnsnullfor these so the corevisitFunctionBodycannot re-enterextractFunctionand recurse.f(x) = exprviaassignmenthandling (not covered in add support for Julia #244).modulenodes —module_definitionmapped tomodulekind so members are namespace-scoped inqualified_name.macrocall_expression— added tocallTypes.tree-sitter-julia.wasmcommitted undersrc/extraction/wasm/(the grammar is not published intree-sitter-wasms@0.1.11; npm-only loading would fail in CI and offline installs). Same vendoring pattern aslua/luau/pascal/scala.Also adds the optional
getNamehook onLanguageExtractor(as proposed in #244) and wires it throughextractName.Test plan
npm run buildnpm test -- --run -t "Julia Extraction"— 11 / 11 tests pass, covering: language detection, top-level functions, signatures, macros, structs without block, abstract types, modules, imports / using, one-linef(x) = expr, and call extraction inside flat bodies.npm test— extraction & installer-targets suites pass.codegraph indexover a Julia workspace (~120.jlfiles) —juliashows up under "Files by Language", withfunction/struct/module/importnodes andcalls/importsedges in the index.Notes for maintainers
tree-sitter-juliais a devDependency only for rebuilding WASM; runtime uses the committedsrc/extraction/wasm/tree-sitter-julia.wasmbinary.main; no merge conflicts.getNamehook onLanguageExtractoris optional and used only by Julia today; existing extractors are unaffected.